package model.service;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import model.dao.RiskIDAO;
import model.dao.RiskIjdbcDAO;
import model.vo.ListVO;
import model.vo.MakindVO;
import model.vo.MasecretVO;
import model.vo.MasecurityVO;
import model.vo.MraassetVO;
import model.vo.MrainfoVO;
import model.vo.MridentyVO;
import model.vo.MsoaVO;
import model.vo.MtkindVO;
import model.vo.MtlistVO;
import model.vo.MvlistVO;
import model.vo.MvscoreVO;
import model.vo.PagingBean;
import model.vo.RiskScenarioVO;
import model.vo.StateReportVO;
import model.vo.TbPublicVO;
import model.vo.TdoaVO;
import model.vo.TracontVO;
import model.vo.TraitemInfoVO;
import model.vo.TreriskVO;
import model.vo.TriskplanVO;
import model.vo.TtriskcalcVO;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.transaction.interceptor.TransactionAspectSupport;

public class RiskIServiceImpl implements RiskIService {
	private RiskIDAO riskIDAO;
	public void setRiskIDAO(RiskIDAO riskIDAO) {
		this.riskIDAO = riskIDAO;
	}
	private RiskIjdbcDAO riskIjdbcDAO;
	public void setRiskIjdbcDAO(RiskIjdbcDAO riskIjdbcDAO) {
		this.riskIjdbcDAO = riskIjdbcDAO;
	}
	//자산유형목록 페이지로 이동
	public List magam_popup(int pro_id) throws SQLException {
		return riskIDAO.magam_popup(pro_id);
	}
	//평가된 카운터 숫자(count)
	@Override
	public int pyungCount(int pro_id, String tableName, String columName, String searchText) throws SQLException {
		// TODO Auto-generated method stub
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		map.put("tableName",tableName);
		map.put("columName",columName);
		if(!searchText.equals(""))
			map.put("searchText", searchText);
		return riskIDAO.pyungCount(map);
	}
	//평가된 카운터 숫자(count)(취약성 평가 부분)
	@Override
	public int vpyungCount(int pro_id, String tableName, String columName, int v_gubun, String searchText) throws SQLException {
		// TODO Auto-generated method stub
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		map.put("tableName",tableName);
		map.put("columName",columName);
		map.put("v_gubun",v_gubun);
		if(!searchText.equals(""))
			map.put("searchText", searchText);
		return riskIDAO.pyungCount(map);
	}
	//최대 순번 구하기
	public int maxNo(String menuName,int pro_id) throws SQLException{
			int maxNo=0;
		if(menuName.equals("makind_maxNo")){
			maxNo=riskIDAO.makind_maxNo(pro_id);
		}else if(menuName.equals("masecurity_maxNo")){
			maxNo=riskIDAO.masecurity_maxNo(pro_id);
		}else if(menuName.equals("masecret_maxNo")){
			maxNo=riskIDAO.masecret_maxNo(pro_id);
		}else if(menuName.equals("mtkind_maxNo")){
			maxNo=riskIDAO.mtkind_maxNo(pro_id);
		}else if(menuName.equals("mvlist_maxNo")){
			maxNo=riskIDAO.mvlist_maxNo(pro_id);
		}else if(menuName.equals("mridenty_maxNo")){
			maxNo=riskIDAO.mridenty_maxNo(pro_id);
		}else if(menuName.equals("mvscore_maxNo")){
			maxNo=riskIDAO.mvscore_maxNo(pro_id);
		}
		return maxNo;
	}
	//[기준수립]
	//(자산유형목록)
	//자산유형목록 페이지로 이동
	public List baseA() throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.baseA();
	}
	//자산유형목록 등록
	public void baseA_insert(TbPublicVO vo) throws SQLException {
		riskIDAO.baseA_insert(vo);
	}
	//자산유형목록 삭제
	@Override
	public void baseA_delete(String base_id,String base_lev1) throws SQLException {
		// TODO Auto-generated method stub
		TbPublicVO vo=new TbPublicVO();
		vo.setBase_id(base_id);
		vo.setBase_lev1(base_lev1);
		riskIDAO.baseA_delete(vo);
	}
	//자산유형목록 수정 페이지로 이동
	@Override
	public TbPublicVO baseA_updatePage(String base_lev2cd) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.baseA_updatePage(base_lev2cd);
	}
	//자산유형목록 수정
	@Override
	public void baseA_update(TbPublicVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.baseA_update(vo);
	}
	
	
	
	//(위협목록)
	//위협목록 페이지로 이동
	@Override
	public List baseT(int pro_id) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.baseT(pro_id);
	}
	//위협목록 등록
	@Override
	public void baseT_insert(MtkindVO vo) throws SQLException {
		riskIDAO.baseT_insert(vo);
	}
	//위협목록 삭제
	@Override
	public void baseT_delete(String base_levAll,int pro_id) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.baseT_delete(base_levAll,pro_id);
	}
	//위협목록 수정 페이지로 이동
	@Override
	public MtkindVO baseT_updatePage(String base_levAll,int pro_id) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.baseT_updatePage(base_levAll,pro_id);
	}
	//위협목록 수정
	@Override
	public void baseT_update(MtkindVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.baseT_update(vo);
	}
	
	//(취약성목록)
	//취약성목록 페이지로 이동
	@Override
	public List baseV(int pro_id) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.baseV(pro_id);
	}

	//취약성목록 등록
	@Override
	public void baseV_insert(MvlistVO vo) throws SQLException {
		riskIDAO.baseV_insert(vo);
	}
	//취약성목록 삭제
	@Override
	public void baseV_delete(String base_levAll,int pro_id) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.baseV_delete(base_levAll,pro_id);
	}
	//취약성목록 수정 페이지로 이동
	@Override
	public MvlistVO baseV_updatePage(String ts_cdAll,int pro_id) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.baseV_updatePage(ts_cdAll,pro_id);
	}
	//취약성목록 수정
	@Override
	public void baseV_update(MvlistVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.baseV_update(vo);
	}
	
	
	//[자산식별]
	//1.자산기준수립
	//(자산유형분류기준)
	//자산유형분류기준 페이지로 이동
	@Override
	public List makind(int pro_id) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.makind(pro_id);
	}
	@Override
	public ArrayList<MakindVO> makindMap(int pro_id) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.makindMap(pro_id);
	}
	//자산유형 생성 팝업 리스트
	public List asset_kind(int pro_id) throws SQLException {
		return riskIDAO.asset_kind(pro_id);
	}
	//자산유형 입력 데이터
	public MakindVO asset_kindData(String base_lev1) throws SQLException {
		return riskIDAO.asset_kindData(base_lev1);
	}
	//최대 순번 구해오기
	/*
	@Override
	public Integer assetMaxNo() throws SQLException {
		// TODO Auto-generated method stub
		return assetDAO.assetMaxNo();
	}
	*/
	//자산유형분류기준 등록
	@Override
	public void makind_insert(MakindVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.makind_insert(vo);
	}
	//자산유형분류기준 삭제
	@Override
	public void makind_delete(String akId,String proId) throws SQLException {
		// TODO Auto-generated method stub
		int ak_id=Integer.parseInt(akId);
		int pro_id=Integer.parseInt(proId);
		MakindVO vo=new MakindVO();
		vo.setAk_id(ak_id);
		vo.setPro_id(pro_id);
		riskIDAO.makind_delete(vo);
	}
	//자산유형분류기준 수정 페이지로 이동
	@Override
	public MakindVO makind_updatePage(String akId,int pro_id) throws SQLException {
		// TODO Auto-generated method stub
		int ak_id=Integer.parseInt(akId);
		MakindVO vo=new MakindVO();
		vo.setAk_id(ak_id);
		vo.setPro_id(pro_id);
		return riskIDAO.makind_updatePage(vo);
	}
	//자산유형분류기준 수정
	@Override
	public void makind_update(MakindVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.makind_update(vo);
	}
	
	
	//(자산보안등급평가기준)
	//자산보안등급평가기준 페이지로 이동
	@Override
	public List masecurity(int pro_id) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.masecurity(pro_id);
	}
	//최대 순번 구해오기
	/*
	@Override
	public Integer assetResultMaxNo() throws SQLException {
		// TODO Auto-generated method stub
		return assetDAO.assetResultMaxNo();
	}
	*/
	//자산보안등급평가기준 등록
	@Override
	public void masecurity_insert(MasecurityVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.masecurity_insert(vo);
	}
	//자산보안등급평가기준 삭제
	@Override
	public void masecurity_delete(String ascuId,String proId) throws SQLException {
		// TODO Auto-generated method stub
		int ascu_id=Integer.parseInt(ascuId);
		int pro_id=Integer.parseInt(proId);
		MasecurityVO vo=new MasecurityVO();
		vo.setAscu_id(ascu_id);
		vo.setPro_id(pro_id);
		riskIDAO.masecurity_delete(vo);
	}
	//자산보안등급평가기준 수정 페이지로 이동
	@Override
	public MasecurityVO masecurity_updatePage(String ascuId,int pro_id) throws SQLException {
		// TODO Auto-generated method stub
		int ascu_id=Integer.parseInt(ascuId);
		MasecurityVO vo=new MasecurityVO();
		vo.setAscu_id(ascu_id);
		vo.setPro_id(pro_id);
		return riskIDAO.masecurity_updatePage(vo);
	}
	//자산보안등급평가기준 수정
	@Override
	public void masecurity_update(MasecurityVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.masecurity_update(vo);
	}
	
	
	//(자산기밀등급분류)
	//자산기밀등급분류 페이지로 이동
	@Override
	public List masecret(int pro_id) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.masecret(pro_id);
	}
	//최대 순번 구해오기
	/*
	@Override
	public Integer assetResultMaxNo() throws SQLException {
		// TODO Auto-generated method stub
		return assetDAO.assetResultMaxNo();
	}
	*/
	//자산기밀등급분류 등록
	@Override
	public void masecret_insert(MasecretVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.masecret_insert(vo);
	}
	//자산기밀등급분류 삭제
	@Override
	public void masecret_delete(String ascId,String proId) throws SQLException {
		// TODO Auto-generated method stub
		int asc_id=Integer.parseInt(ascId);
		int pro_id=Integer.parseInt(proId);
		MasecretVO vo=new MasecretVO();
		vo.setAsc_id(asc_id);
		vo.setPro_id(pro_id);
		riskIDAO.masecret_delete(vo);
	}
	//자산기밀등급분류 수정 페이지로 이동
	@Override
	public MasecretVO masecret_updatePage(String ascId,int pro_id) throws SQLException {
		// TODO Auto-generated method stub
		int asc_id=Integer.parseInt(ascId);
		MasecretVO vo=new MasecretVO();
		vo.setAsc_id(asc_id);
		vo.setPro_id(pro_id);
		return riskIDAO.masecret_updatePage(vo);
	}
	//자산기밀등급분류 수정
	@Override
	public void masecret_update(MasecretVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.masecret_update(vo);
	}
	
	
	
	//2.자산식별및평가
	//(RA정보자산식별)
	//RA정보자산식별 페이지로 이동
	public List mrainfo(Map map) throws SQLException{
		return riskIDAO.mrainfo(map);
	}
	//RA정보코드 유효성 검사
	@Override
	public boolean searchRainfoId(String rainfo_id,String proId) throws SQLException {
		// TODO Auto-generated method stub
		int pro_id=Integer.parseInt(proId);
		MrainfoVO vo=new MrainfoVO();
		vo.setRainfo_id(rainfo_id);
		vo.setPro_id(pro_id);
		return riskIDAO.searchRainfoId(vo);
	}
	//RA정보자산식별 등록
	@Override
	public void mrainfo_insert(MrainfoVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.mrainfo_insert(vo);
	}
	//RA정보자산식별 등록(엑셀)
	@Override
	public void mrainfo_insertExcel(Map map) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.mrainfo_insertExcel(map);
	}
	//RA정보자산식별 수정 페이지로 이동
	@Override
	public MrainfoVO mrainfo_updatePage(String rainfo_id, int pro_id) throws SQLException {
		// TODO Auto-generated method stub
		MrainfoVO vo=new MrainfoVO();
		vo.setRainfo_id(rainfo_id);
		vo.setPro_id(pro_id);
		return riskIDAO.mrainfo_updatePage(vo);
	}
	//RA정보자산식별 수정
	@Override
	public void mrainfo_update(MrainfoVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.mrainfo_update(vo);
	}
	//RA정보자산식별 삭제
	@Override
	public void mrainfo_delete(String rainfo_id,String proId) throws SQLException {
		// TODO Auto-generated method stub
		int pro_id=Integer.parseInt(proId);
		TracontVO vo=new TracontVO();
		vo.setRainfo_id(rainfo_id);
		vo.setPro_id(pro_id);
		riskIDAO.mrainfo_delete(vo);
	}
	
	
	//컨테이너 리스트
	@Override
	public List tracont_list(int pro_id) throws SQLException{
		return riskIDAO.tracont_list(pro_id);
	}
	
	
	
	//컨테이너2(공통테이블) 리스트
	@Override
	public List tracont2_list(int pro_id) throws SQLException{
		return riskIDAO.tracont2_list(pro_id);
	}
	
	//컨테이너1(개별테이블) 리스트
	@Override
	public List tracont1_list(String proId, String rainfo_id) throws SQLException{
		TracontVO vo=new TracontVO();
		int pro_id=Integer.parseInt(proId);
		vo.setPro_id(pro_id);
		vo.setRainfo_id(rainfo_id);
		return riskIDAO.tracont1_list(vo);
	}
	//컨테이너1(개별테이블) 수정테이블 값 
	@Override
	public TracontVO tracont1_listByRacontNm(String proId, String rainfo_id, String racont_nm) throws SQLException{
		TracontVO vo=new TracontVO();
		int pro_id=Integer.parseInt(proId);
		vo.setPro_id(pro_id);
		vo.setRainfo_id(rainfo_id);
		vo.setRacont_nm(racont_nm);
		return riskIDAO.tracont1_listByRacontNm(vo);
	}
	
	//공통 컨테이너 사용여부 검사
	@Override
	public boolean searchUseTracont2(String proId, String base_lev1, String racont_nm) throws SQLException {
		// TODO Auto-generated method stub
		TracontVO vo=new TracontVO();
		int pro_id=Integer.parseInt(proId);
		vo.setPro_id(pro_id);
		vo.setBase_lev1(base_lev1);
		vo.setRacont_nm(racont_nm);
		return riskIDAO.searchUseTracont2(vo);
	}
	//컨테이너1 등록
	@Override
	public void tracont1_insert(String proId, String rainfo_id, String base_lev1, String racont_nm) throws SQLException{
		TracontVO vo=new TracontVO();
		int pro_id=Integer.parseInt(proId);
		vo.setPro_id(pro_id);
		vo.setRainfo_id(rainfo_id);
		vo.setBase_lev1(base_lev1);
		vo.setRacont_nm(racont_nm);
		riskIDAO.tracont1_insert(vo);
	}
	//컨테이너1 삭제
	@Override
	public void tracont1_delete(String proId, String rainfo_id, String racont_nm) throws SQLException{
		TracontVO vo=new TracontVO();
		int pro_id=Integer.parseInt(proId);
		vo.setPro_id(pro_id);
		vo.setRainfo_id(rainfo_id);
		vo.setRacont_nm(racont_nm);
		riskIDAO.tracont1_delete(vo);
	}
	//공통 컨테이너로 넘어간 데이터 컨테이너1에서 삭제
	@Override
	public void tracont1_deleteByRacontNm(String proId, String racont_nm) throws SQLException{
		TracontVO vo=new TracontVO();
		int pro_id=Integer.parseInt(proId);
		vo.setPro_id(pro_id);
		vo.setRacont_nm(racont_nm);
		riskIDAO.tracont1_deleteByRacontNm(vo);
	}
	//컨테이너2 등록
	@Override
	public void tracont2_insert(String proId, String base_lev1, String racont_nm) throws SQLException{
		TracontVO vo=new TracontVO();
		int pro_id=Integer.parseInt(proId);
		vo.setPro_id(pro_id);
		vo.setBase_lev1(base_lev1);
		vo.setRacont_nm(racont_nm);
		riskIDAO.tracont2_insert(vo);
	}
	//컨테이너2 삭제
	@Override
	public void tracont2_delete(String proId, String racont_nm) throws SQLException{
		TracontVO vo=new TracontVO();
		int pro_id=Integer.parseInt(proId);
		vo.setPro_id(pro_id);
		vo.setRacont_nm(racont_nm);
		riskIDAO.tracont2_delete(vo);
	}
	
	
	//컨테이너 등록(엑셀)
	@Override
	public void tracont_insertExcel(Map map) throws SQLException{
		riskIDAO.tracont_insertExcel(map);
	}
	/*
	//컨테이너 정보 변경
	public List changeCon(String proId,String rainfo_id) throws SQLException{
		int pro_id=Integer.parseInt(proId);
		TracontVO vo=new TracontVO();
		vo.setPro_id(pro_id);
		vo.setRainfo_id(rainfo_id);
		return riskIDAO.changeCon(vo);
	}
	//컨테이너 삭제
	@Override
	public void mrainfoCon_delete(String rainfo_id,String racontId,String proId) throws SQLException {
		// TODO Auto-generated method stub
		int pro_id=Integer.parseInt(proId);
		int racont_id=Integer.parseInt(racontId);
		TracontVO vo=new TracontVO();
		vo.setRainfo_id(rainfo_id);
		vo.setRacont_id(racont_id);
		vo.setPro_id(pro_id);
		riskIDAO.mrainfoCon_delete(vo);
	}
	
	//컨테이너 등록
	@Override
	public void tracont_insert(TracontVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.tracont_insert(vo);
	}
	//컨테이너 수정
	@Override
	public void tracont_update(TracontVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.tracont_update(vo);
	}
	//컨테이너 등록 테이블 값 확인 및 생성
	@Override
	public TracontVO tracontTable(String rainfo_id,String racontId,String akId,String proId) throws SQLException {
		int pro_id=Integer.parseInt(proId);
		int ak_id=Integer.parseInt(akId);
		int racont_id=Integer.parseInt(racontId);
		TracontVO vo=new TracontVO();
		vo.setRainfo_id(rainfo_id);
		vo.setRacont_id(racont_id);
		vo.setAk_id(ak_id);
		vo.setPro_id(pro_id);
		return riskIDAO.tracontTable(vo);
	}
	//컨테이너 최대 순번 구해오기
	@Override
	public Integer tracont_maxNo(String rainfo_id, String proId) throws SQLException{
		int pro_id=Integer.parseInt(proId);
		TracontVO vo=new TracontVO();
		vo.setRainfo_id(rainfo_id);
		vo.setPro_id(pro_id);
		return riskIDAO.tracont_maxNo(vo);
	}
	*/
	
	
	//(RA정보자산평가)
	//RA정보자산평가 페이지로 이동
	//public List mrainfop(int pro_id) throws SQLException{
	//	return riskIDAO.mrainfop(pro_id);
	//}
	public List mrainfop(Map map) throws SQLException{
		return riskIDAO.mrainfop(map);
	}
	//RA정보자산평가 수정 페이지로 이동
	@Override
	public MrainfoVO mrainfop_updatePage(String rainfo_id, int pro_id) throws SQLException {
		// TODO Auto-generated method stub
		MrainfoVO vo=new MrainfoVO();
		vo.setRainfo_id(rainfo_id);
		vo.setPro_id(pro_id);
		return riskIDAO.mrainfop_updatePage(vo);
	}
	//RA정보자산평가 기밀등급(역순)
	@Override
	public List secretLevel(int pro_id) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.secretLevel(pro_id);
	}
	//RA정보자산평가 수정
	@Override
	public void mrainfop_update(MrainfoVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.mrainfop_update(vo);
	}
	
	//(자산현황)
	//자산현황 페이지로 이동
	@Override
	public List mastate(int pro_id, ArrayList<MakindVO> list) throws SQLException {
		// TODO Auto-generated method stub
		return riskIjdbcDAO.mastate(pro_id, list);
	}
	
	
	
	//(RA정보식별)
	//RA정보식별 페이지로 이동
	public List mraasset(Map map) throws SQLException{
		return riskIDAO.mraasset(map);
	}
	//컨테이너 명칭 및 갯수
	public List distinctRacontNmAndCount(int pro_id) throws SQLException{
		return riskIDAO.distinctRacontNmAndCount(pro_id);
	}
	//컨테이너에 매핑되어있는 ra정보들
	public List mappingInfoByRaitemNm(int pro_id,String raitem_nm, String gub) throws SQLException{
		MraassetVO vo=new MraassetVO();
		vo.setPro_id(pro_id);
		vo.setRaitem_nm(raitem_nm);
		vo.setGub(gub);
		return riskIDAO.mappingInfoByRaitemNm(vo);
	}
	//총 자산수 : 총 컨테이너 수(distinct)
	@Override
	public Integer totalRacontCount(int pro_id) throws SQLException {
		return riskIDAO.totalRacontCount(pro_id);
	}
	//총 매핑된 자산수
	@Override
	public Integer totalMCount(int pro_id,String raitem_nm,String gub) throws SQLException {
		MraassetVO vo=new MraassetVO();
		vo.setPro_id(pro_id);
		vo.setRaitem_nm(raitem_nm);
		vo.setGub(gub);
		return riskIDAO.totalMCount(vo);
	}
	//저장시킬 RA정보
	public MraassetVO mraasset_insertData(String proId,String raitem_nm,String gub) throws SQLException{
		MraassetVO vo=new MraassetVO();
		int pro_id=Integer.parseInt(proId);
		vo.setPro_id(pro_id);
		vo.setRaitem_nm(raitem_nm);
		vo.setGub(gub);
		return riskIDAO.mraasset_insertData(vo);
	}
	
	//요구사항
	@Override
	public List mraasset_memoData(int pro_id, String raitem_nm,String gub) throws SQLException {
		MraassetVO vo=new MraassetVO();
		vo.setPro_id(pro_id);
		vo.setRaitem_nm(raitem_nm);
		vo.setGub(gub);
		return riskIDAO.mraasset_memoData(vo);
	}
	//연관 정보 갯수 새창열기
	public List mappingInfoByRaitemId(int pro_id,String raitem_id) throws SQLException{
		TraitemInfoVO vo=new TraitemInfoVO();
		vo.setPro_id(pro_id);
		vo.setRaitem_id(raitem_id);
		return riskIDAO.mappingInfoByRaitemId(vo);
	}
	//RA정보식별 수정 페이지로 이동
	@Override
	public MraassetVO mraasset_updatePage(int pro_id,String raitem_id) throws SQLException {
		// TODO Auto-generated method stub
		MraassetVO vo=new MraassetVO();
		vo.setRaitem_id(raitem_id);
		vo.setPro_id(pro_id);
		return riskIDAO.mraasset_updatePage(vo);
	}
	//RA정보식별 수정
	@Override
	public void mraasset_update(MraassetVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.mraasset_update(vo);
	}
	//RA정보식별 최대순번 구하기
	@Override
	public String mraasset_maxNo(int pro_id,String base_lev1) throws SQLException {
		// TODO Auto-generated method stub
		MraassetVO vo=new MraassetVO();
		vo.setBase_lev1(base_lev1);
		vo.setPro_id(pro_id);
		return riskIDAO.mraasset_maxNo(vo);
	}
	//ascLevel
	@Override
	public String ascLevel(MraassetVO vo) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.ascLevel(vo);
	}
	//RA정보식별 등록
	@Override
	public void mraasset_insert(MraassetVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.mraasset_insert(vo);
	}
	//RA정보식별 등록
	@Override
	public void mraasset_insertExcel(Map map) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.mraasset_insertExcel(map);
	}
	//traitem_info 등록
	@Override
	public void traitemInfoInsert(int pro_id, String raitem_id, String rainfo_id) throws SQLException {
		TraitemInfoVO vo=new TraitemInfoVO();
		vo.setPro_id(pro_id);
		vo.setRaitem_id(raitem_id);
		vo.setRainfo_id(rainfo_id);
		riskIDAO.traitemInfoInsert(vo);
	}
	//RA정보식별 삭제
	@Override
	public void mraasset_delete(String raitem_id,String proId) throws SQLException {
		// TODO Auto-generated method stub
		int pro_id=Integer.parseInt(proId);
		MraassetVO vo=new MraassetVO();
		vo.setPro_id(pro_id);
		vo.setRaitem_id(raitem_id);
		riskIDAO.mraasset_delete(vo);
	}
	
	
	
	//(RA정보평가)
	//RA정보평가 페이지로 이동
	public List mraassetp(Map map) throws SQLException{
		return riskIDAO.mraassetp(map);
	}
	//RA정보평가 수정 페이지로 이동
	@Override
	public MraassetVO mraassetp_updatePage(int pro_id,String raitem_id) throws SQLException {
		// TODO Auto-generated method stub
		MraassetVO vo=new MraassetVO();
		vo.setRaitem_id(raitem_id);
		vo.setPro_id(pro_id);
		return riskIDAO.mraassetp_updatePage(vo);
	}
	//RA정보평가 수정
	@Override
	public void mraassetp_update(MraassetVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.mraassetp_update(vo);
	}
	
	
	
	
	//[위협식별]
	//(분류기준수립)
	//분류기준수립 페이지로 이동
	@Override
	public List mtkind(Map map) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.mtkind(map);
	}
	//분류기준수립 페이지로 이동(조회)
	public List mtkindSearchBaseLev1(int pro_id, String base_lev1) throws SQLException {
		// TODO Auto-generated method stub
		MtkindVO vo=new MtkindVO();
		vo.setPro_id(pro_id);
		vo.setBase_lev1(base_lev1);
		return riskIDAO.mtkindSearchBaseLev1(vo);
	}
	//mtkind 조회 기준
	@Override
	public List distMtkind(int pro_id) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.distMtkind(pro_id);
	}
	@Override
	public ArrayList<MtkindVO> mtkindArrayList(Map map) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.mtkindArrayList(map);
	}
	
	//tbtkind 조회 기준
	@Override
	public List distTbtkind(int pro_id) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.distTbtkind(pro_id);
	}
	//분류기준수립 데이터(tbtkind) 생성 팝업 리스트
	public List tbtkind_data(int pro_id) throws SQLException {
		return riskIDAO.tbtkind_data(pro_id);
	}
	//분류기준수립 데이터(tbtkind)생성 팝업리스트(조회)
	public List tbtkindSearchBaseLev1(int pro_id, String base_lev1) throws SQLException {
		// TODO Auto-generated method stub
		MtkindVO vo=new MtkindVO();
		vo.setPro_id(pro_id);
		vo.setBase_lev1(base_lev1);
		return riskIDAO.tbtkindSearchBaseLev1(vo);
	}
	//분류기준수립 등록
	@Override
	public void mtkind_insert(MtkindVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.mtkind_insert(vo);
	}
	//분류기준수립 입력할 데이터 가져오기
	@Override
	public MtkindVO tbtkind_InsertData(String base_levAll, int pro_id)
			throws SQLException {
		// TODO Auto-generated method stub
		MtkindVO vo=new MtkindVO();
		String[] str=base_levAll.split("\\|");
		String base_lev1=str[0];
		String base_lev2=str[1];
		String base_lev3=str[2];
		vo.setPro_id(pro_id);
		vo.setBase_lev1(base_lev1);
		vo.setBase_lev2(base_lev2);
		vo.setBase_lev3(base_lev3);
		return riskIDAO.tbtkind_InsertData(vo);
	}
	//분류기준수립 삭제
	@Override
	public void mtkind_delete(String tkId,String proId) throws SQLException {
		// TODO Auto-generated method stub
		int tk_id=Integer.parseInt(tkId);
		int pro_id=Integer.parseInt(proId);
		MtkindVO vo=new MtkindVO();
		vo.setTk_id(tk_id);
		vo.setPro_id(pro_id);
		riskIDAO.mtkind_delete(vo);
	}
	//분류기준수립 수정 페이지로 이동
	@Override
	public MtkindVO mtkind_updatePage(String tkId, int pro_id)
			throws SQLException {
		// TODO Auto-generated method stub
		int tk_id=Integer.parseInt(tkId);
		MtkindVO vo=new MtkindVO();
		vo.setTk_id(tk_id);
		vo.setPro_id(pro_id);
		return riskIDAO.mtkind_updatePage(vo);
	}
	//분류기준수립 수정
	@Override
	public void mtkind_update(MtkindVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.mtkind_update(vo);
	}
	//위협유형 팝업 새창열기
	//변경(공통 테이블 값 정보 가져오기) 
	@Override
	public List tbpublicData(String base_id) throws SQLException{
		return riskIDAO.tbpublicData(base_id);
	}
	//팝업 내용 가져오기
	@Override
	public TbPublicVO tbpublicDataSelectByBaseLev1(String base_id, String base_lev1) throws SQLException {
		HashMap map=new HashMap();
		map.put("base_id",base_id);
		map.put("base_lev1",base_lev1);
		return riskIDAO.tbpublicDataSelectByBaseLev1(map);
	}
	//변경(공통 테이블 값 정보 가져오기) (역순)
	@Override
	public List tbpublicDataDesc(String base_id) throws SQLException{
		return riskIDAO.tbpublicDataDesc(base_id);
	}
	
	
	//(위협목록작성)
	//위협목록작성 페이지로 이동
	@Override
	public List mtlist(Map map) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.mtlist(map);
	}
	//위협목록작성 연관자산 팝업창
	@Override
	public List t_akind_popup(String pro_id, String base_lev1, String base_lev2, String base_lev3) throws SQLException {
		HashMap map=new HashMap();
		map.put("pro_id",Integer.parseInt(pro_id));
		map.put("base_lev1",base_lev1);
		map.put("base_lev2",base_lev2);
		map.put("base_lev3",base_lev3);
		return riskIDAO.t_akind_popup(map);
	}
	//mtlist 조회 기준
	@Override
	public List distMtlist(int pro_id) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.distMtlist(pro_id);
	}
	//위협목록작성 페이지로 이동(조회)
	public List mtlistSearchBaseLev1(int pro_id, String base_lev1) throws SQLException {
		// TODO Auto-generated method stub
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		map.put("base_lev1",base_lev1);
		return riskIDAO.mtlistSearchBaseLev1(map);
	}
	//위협목록작성 등록 새창의 내용
	@Override
	public List openTkList(int pro_id) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.openTkList(pro_id);
	}
	//위협목록작성 등록 새창의 내용 (조회)
	public List openTkListSearchBaseLev1(int pro_id, String base_lev1) throws SQLException {
		// TODO Auto-generated method stub
		MtkindVO vo=new MtkindVO();
		vo.setPro_id(pro_id);
		vo.setBase_lev1(base_lev1);
		return riskIDAO.openTkListSearchBaseLev1(vo);
	}
	//위협목록작성 등록
	@Override
	public void mtlist_insert(int tk_id,String proId) throws SQLException {
		// TODO Auto-generated method stub
		//int tk_id=Integer.parseInt(tkId);
		int pro_id=Integer.parseInt(proId);
		int tl_id=riskIDAO.mtlist_maxNo(pro_id);
		MtlistVO vo=new MtlistVO();
		vo.setTk_id(tk_id);
		vo.setPro_id(pro_id);
		vo.setTl_id(tl_id);
		riskIDAO.mtlist_insert(vo);
	}
	//위협목록작성 삭제
	@Override
	public void mtlist_delete(String tlId,String proId) throws SQLException {
		// TODO Auto-generated method stub
		int tl_id=Integer.parseInt(tlId);
		int pro_id=Integer.parseInt(proId);
		MtlistVO vo=new MtlistVO();
		vo.setTl_id(tl_id);
		vo.setPro_id(pro_id);
		riskIDAO.mtlist_delete(vo);
	}
	//위협목록작성 수정 페이지로 이동
	@Override
	public MtlistVO mtlist_updatePage(String tlId, int pro_id)
			throws SQLException {
		// TODO Auto-generated method stub
		int tl_id=Integer.parseInt(tlId);
		MtlistVO vo=new MtlistVO();
		vo.setTl_id(tl_id);
		vo.setPro_id(pro_id);
		return riskIDAO.mtlist_updatePage(vo);
	}
	//위협목록작성 수정
	@Override
	public void mtlist_update(MtlistVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.mtlist_update(vo);
	}
	
	
	
	
	
	
	//[취약성식별]
	//(취약성식별)
	//취약성식별 페이지로 이동
	@Override
	public List mvlist(Map map) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.mvlist(map);
	}
	//취약성체크리스트 데이터(tbvkind) 생성 팝업 리스트
	public List tbvkind_data(MvlistVO vo) throws SQLException {
		return riskIDAO.tbvkind_data(vo);
	}
	//분류기준수립 입력할 데이터 가져오기
	@Override
	public MvlistVO tbvkind_InsertData(String ts_cdAll, int pro_id)
			throws SQLException {
		// TODO Auto-generated method stub
		MvlistVO vo=new MvlistVO();
		String[] str=ts_cdAll.split("\\|");
		String ts_cd1=str[0];
		String ts_cd2=str[1];
		String ts_cd3=str[2];
		String ts_cd4=str[3];
		vo.setPro_id(pro_id);
		vo.setTs_cd1(ts_cd1);
		vo.setTs_cd2(ts_cd2);
		vo.setTs_cd3(ts_cd3);
		vo.setTs_cd4(ts_cd4);
		return riskIDAO.tbvkind_InsertData(vo);
	}
	//tbpublic 의 base_lev1 like 함수
	@Override
	public List tbpublicVLData(TbPublicVO vo) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.tbpublicVLData(vo);
	}
	//취약성식별 수정 페이지로 이동
	@Override
	public MvlistVO mvlist_updatePage(String vId, int pro_id)
			throws SQLException {
		// TODO Auto-generated method stub
		int v_id=Integer.parseInt(vId);
		MvlistVO vo=new MvlistVO();
		vo.setV_id(v_id);
		vo.setPro_id(pro_id);
		return riskIDAO.mvlist_updatePage(vo);
	}
	//취약성식별 수정
	@Override
	public void mvlist_update(MvlistVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.mvlist_update(vo);
	}
	//취약성식별 등록
	@Override
	public void mvlist_insert(MvlistVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.mvlist_insert(vo);
	}
	//취약성식별 삭제
	@Override
	public void mvlist_delete(String vId,String proId) throws SQLException {
		// TODO Auto-generated method stub
		int v_id=Integer.parseInt(vId);
		int pro_id=Integer.parseInt(proId);
		MvlistVO vo=new MvlistVO();
		vo.setV_id(v_id);
		vo.setPro_id(pro_id);
		riskIDAO.mvlist_delete(vo);
	}
	//취약성 식별 등록 조회 구분  1
	@Override
	public List mvlistDistinct1() throws SQLException {
		return riskIDAO.mvlistDistinct1();
	}
	//취약성 식별 등록 조회 구분  2
	@Override
	public List mvlistDistinct2(MvlistVO vo) throws SQLException {
		return riskIDAO.mvlistDistinct2(vo);
	}
	//취약성 식별 등록 조회 구분  3
	@Override
	public List mvlistDistinct3(MvlistVO vo) throws SQLException {
		return riskIDAO.mvlistDistinct3(vo);
	}
	
	
	
	
	
	
	//[취약성평가]
	//(취약성평가)
	//취약성평가 페이지로 이동
	@Override
	public List mvlistp(int pro_id) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.mvlistp(pro_id);
	}
	//자산식별된 자산유형목록
	@Override
	public List<String> assetListSelectByMraasset(int pro_id) throws SQLException {
		return riskIDAO.assetListSelectByMraasset(pro_id);
	}
	//취약성평가 등록 페이지
	@Override
	public List mvlistp_insertPage(MvlistVO vo) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.mvlistp_insertPage(vo);
	}
	//취약성평가 등록
	@Override
	public void mvlistp_insert(MvlistVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.mvlistp_insert(vo);
	}
	//취약성평가 삭제
	@Override
	public void mvlistp_delete(String vId,String proId) throws SQLException {
		// TODO Auto-generated method stub
		int v_id=Integer.parseInt(vId);
		int pro_id=Integer.parseInt(proId);
		MvlistVO vo=new MvlistVO();
		vo.setV_id(v_id);
		vo.setPro_id(pro_id);
		riskIDAO.mvlistp_delete(vo);
	}
	//취약성평가 수정 페이지로 이동
	@Override
	public MvlistVO mvlistp_updatePage(String vId, int pro_id)
			throws SQLException {
		// TODO Auto-generated method stub
		int v_id=Integer.parseInt(vId);
		MvlistVO vo=new MvlistVO();
		vo.setV_id(v_id);
		vo.setPro_id(pro_id);
		return riskIDAO.mvlistp_updatePage(vo);
	}
	//취약성평가 수정
	@Override
	public void mvlistp_update(MvlistVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.mvlistp_update(vo);
	}
	// 취약성 평가된 식별 숫자(count)
	@Override
	public Map tvchecklistCount(int pro_id) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.tvchecklistCount(pro_id);
	}

	
	
	//(자산공통 취약성 평가)
	//자산공통 취약성 평가 페이지로 이동
	@Override
	public List mavlistp(Map map) throws SQLException {
		// TODO Auto-generated method stub
		//MvlistVO vo=new MvlistVO();
		//vo.setPro_id(pro_id);
		//vo.setV_gubun(v_gubun);
		return riskIDAO.mavlistp(map);
	}
	//연관자산
	@Override
	public List v_raitem_select(int pro_id, String ts_cd1, String ts_cd2, String ts_cd3) throws SQLException {
		// TODO Auto-generated method stub
		MvlistVO vo=new MvlistVO();
		vo.setPro_id(pro_id);
		vo.setTs_cd1(ts_cd1);
		vo.setTs_cd2(ts_cd2);
		vo.setTs_cd3(ts_cd3);
		return riskIDAO.v_raitem_select(vo);
	}
	//자산공통 취약성 평가 삭제
	@Override
	public void mavlistp_delete(String vId,String proId, String vGubun) throws SQLException {
		// TODO Auto-generated method stub
		int v_id=Integer.parseInt(vId);
		int pro_id=Integer.parseInt(proId);
		int v_gubun=Integer.parseInt(vGubun);
		MvlistVO vo=new MvlistVO();
		vo.setV_id(v_id);
		vo.setPro_id(pro_id);
		vo.setV_gubun(v_gubun);
		riskIDAO.mavlistp_delete(vo);
	}
	//자산공통 취약성 평가 수정 페이지로 이동
	@Override
	public MvlistVO mavlistp_updatePage(int pro_id, String vId, String vGubun)
			throws SQLException {
		// TODO Auto-generated method stub
		int v_id=Integer.parseInt(vId);
		int v_gubun=Integer.parseInt(vGubun);
		MvlistVO vo=new MvlistVO();
		vo.setV_id(v_id);
		vo.setPro_id(pro_id);
		vo.setV_gubun(v_gubun);
		return riskIDAO.mavlistp_updatePage(vo);
	}
	//자산공통 취약성 평가 수정
	@Override
	public void mavlistp_update(MvlistVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.mavlistp_update(vo);
	}
	//자산공통 취약성 평가 등록
	@Override
	public void mavlistp_insert(int pro_id) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.mavlistp_insert(pro_id);
	}
	
	
	//[위험시나리오]
	//(위험시나리오)
	//위험시나리오 페이지로 이동
	@Override
	public List mridenty(Map map) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.mridenty(map);
	}
	//위험시나리오 페이지로 이동(조회)
	@Override
	public List mridentySearch(int pro_id, String ascuId, String ascId) throws SQLException {
		// TODO Auto-generated method stub
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		map.put("ascu_id",Integer.parseInt(ascuId));
		map.put("asc_id",Integer.parseInt(ascId));
		return riskIDAO.mridentySearch(map);
	}
	//위험시나리오 생성
	/*
	public List makeRiskScenario(int pro_id, String ascuId, String ascId) throws SQLException {
		// TODO Auto-generated method stub
		RiskScenarioVO vo=new RiskScenarioVO();
		vo.setPro_id(pro_id);
		int ascu_id=Integer.parseInt(ascuId);
		vo.setAscu_id(ascu_id);
		int asc_id=Integer.parseInt(ascId);
		vo.setAsc_id(asc_id);
		return riskIDAO.makeRiskScenario(vo);
	}
	*/
	@Override
	public ListVO makeRiskScenario(int pro_id, String ascuId, String ascId, String page) throws SQLException {
		// TODO Auto-generated method stub
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		map.put("ascu_id",Integer.parseInt(ascuId));
		map.put("asc_id",Integer.parseInt(ascId));
		map.put("page", page);
		map.put("tNum",util.CommonConstants.CONTENT_NUMBER_PER_PAGE);
		List list=riskIDAO.makeRiskScenario(map);
		int total=riskIDAO.totalmakeRiskScenario(map);
		PagingBean pagingbean=new PagingBean(total,Integer.parseInt(page));
		ListVO lvo=new ListVO(list, pagingbean);
		return lvo;
	}
	//위험시나리오 데이터 받아오기
	@Override
	public MridentyVO makeRiskScenarioData(RiskScenarioVO vo) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.makeRiskScenarioData(vo);
	}
	//risk_id 구하기
	@Override
	public String mridenty_max_risk_id(MridentyVO vo) throws SQLException {
		return riskIDAO.mridenty_max_risk_id(vo);
	}
	//시나리오 카운터 수
	@Override
	public Integer scenarioCount(int pro_id, String ascuId, String ascId) throws SQLException {
		RiskScenarioVO vo=new RiskScenarioVO();
		vo.setPro_id(pro_id);
		int ascu_id=Integer.parseInt(ascuId);
		vo.setAscu_id(ascu_id);
		int asc_id=Integer.parseInt(ascId);
		vo.setAsc_id(asc_id);
		return riskIDAO.scenarioCount(vo);
	}
	//위험식별시나리오 등록
	@Override
	//public void mridenty_insert(MridentyVO vo) throws SQLException {
	public void mridenty_insert(Map map) throws SQLException {
		// TODO Auto-generated method stub
		//riskIDAO.mridenty_insert(vo);
		riskIDAO.mridenty_insert(map);
	}
	//위험 시나리오 등록(dao에서 루프 돌리는 방식)(속도면에서 더 빨라서 바꿨음)
	public void mridenty_insertTest(int pro_id, int ascu_id, int asc_id, String[] hiddenCode) throws SQLException{
		//riskIjdbcDAO.mridenty_insertTest(pro_id,ascu_id,asc_id, hiddenCode);
		riskIDAO.mridenty_insertTest(pro_id,ascu_id,asc_id, hiddenCode);
	}
	//위험식별시나리오 삭제
	@Override
	public void mridenty_delete(String risk_id,String proId) throws SQLException {
		// TODO Auto-generated method stub
		int pro_id=Integer.parseInt(proId);
		MridentyVO vo=new MridentyVO();
		vo.setPro_id(pro_id);
		vo.setRisk_id(risk_id);
		riskIDAO.mridenty_delete(vo);
	}
	//위험식별시나리오 수정 페이지로 이동
	@Override
	public MridentyVO mridenty_updatePage(String risk_id, int pro_id)
			throws SQLException {
		// TODO Auto-generated method stub
		MridentyVO vo=new MridentyVO();
		vo.setPro_id(pro_id);
		vo.setRisk_id(risk_id);
		return riskIDAO.mridenty_updatePage(vo);
	}
	//위협목록
	@Override
	public MtlistVO mtlistData(int tk_id, int pro_id)
			throws SQLException {
		// TODO Auto-generated method stub
		MtlistVO vo=new MtlistVO();
		vo.setTk_id(tk_id);
		vo.setPro_id(pro_id);
		return riskIDAO.mtlistData(vo);
	}
	//위험식별시나리오 수정
	@Override
	public void mridenty_update(MridentyVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.mridenty_update(vo);
	}
	//자산 연관정보 갯수
	@Override
	public Integer mraassetCount(int pro_id,String raitem_id) throws SQLException {
		// TODO Auto-generated method stub
		MraassetVO vo=new MraassetVO();
		vo.setRaitem_id(raitem_id);
		vo.setPro_id(pro_id);
		return riskIDAO.mraassetCount(vo);
	}
	//위험시나리오 ciamemo
	@Override
	public MraassetVO riskScenarioMemo(int pro_id,String raitem_id) throws SQLException {
		// TODO Auto-generated method stub
		MraassetVO vo=new MraassetVO();
		vo.setRaitem_id(raitem_id);
		vo.setPro_id(pro_id);
		return riskIDAO.riskScenarioMemo(vo);
	}

	//[보안통제효과성평가]
	//(보안통제효과성평가) 
	//보안통제효과성평가 페이지로 이동
	@Override
	public List mbbtlist(Map map) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.mbbtlist(map);
	}
	//보안통제효과성평가 수정
	@Override
	public void mbbtlist_update(MvlistVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.mbbtlist_update(vo);
	}
	
	
	
	
	//[위험 수준 산정 및 평가]
	//(취약성점수 산정기준)
	//취약성점수 산정기준 페이지로 이동
	@Override
	public List mvscore(int pro_id) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.mvscore(pro_id);
	}
	//역순
	@Override
	public List mvscoreDesc(int pro_id) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.mvscoreDesc(pro_id);
	}
	
	/*
	//최대 순번 구해오기
	@Override
	public Integer assetResultMaxNo() throws SQLException {
		// TODO Auto-generated method stub
		return assetDAO.assetResultMaxNo();
	}
	*/
	//취약성점수 산정기준 등록
	@Override
	public void mvscore_insert(MvscoreVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.mvscore_insert(vo);
	}
	//취약성점수 산정기준 삭제
	@Override
	public void mvscore_delete(String vpId,String proId) throws SQLException {
		// TODO Auto-generated method stub
		int vp_id=Integer.parseInt(vpId);
		int pro_id=Integer.parseInt(proId);
		MvscoreVO vo=new MvscoreVO();
		vo.setVp_id(vp_id);
		vo.setPro_id(pro_id);
		riskIDAO.mvscore_delete(vo);
	}
	//취약성점수 산정기준 수정 페이지로 이동
	@Override
	public MvscoreVO mvscore_updatePage(String vpId,int pro_id) throws SQLException {
		// TODO Auto-generated method stub
		int vp_id=Integer.parseInt(vpId);
		MvscoreVO vo=new MvscoreVO();
		vo.setVp_id(vp_id);
		vo.setPro_id(pro_id);
		return riskIDAO.mvscore_updatePage(vo);
	}
	//취약성점수 산정기준 수정
	@Override
	public void mvscore_update(MvscoreVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.mvscore_update(vo);
	}
	
	//(위험등급 결정기준)
	//(위험등급 결정기준)
	//DoA 기준 점수 호출
	@Override
	public List tdoa(int pro_id) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.tdoa(pro_id);
	}
	//DoA 기준 점수 호출(base)
	public List tdoa_base() throws SQLException {
		return riskIDAO.tdoa_base();
	}
	
	//위험등급 결정기준 등록
	public void mrlevel_insert(String base_id, String base_lev1, String base_lev2, String baseCnt) throws SQLException{
		TbPublicVO vo=new TbPublicVO();
		vo.setBase_id(base_id);
		vo.setBase_lev1(base_lev1);
		vo.setBase_lev2(base_lev2);
		float base_cnt=Float.parseFloat(baseCnt);
		vo.setBase_cnt(base_cnt);
		riskIDAO.mrlevel_insert(vo);
	}

	//위험등급 결정 기준(DoA) 등록
	@Override
	public void DoA_insert(ArrayList<TdoaVO> list) throws SQLException {
		// TODO Auto-generated method stub
		//list를 for문을 돌려서 하나씩 insert
		for(TdoaVO vo:list){
			riskIDAO.DoA_insert(vo);
		}
	}
	
	
	//(위험수준산정)
	//위험수준산정 페이지로 이동
	@Override
	public List mrscore(Map map) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.mrscore(map);
	}
	//위험수준산정 수정 페이지로 이동
	@Override
	public MridentyVO mrscore_updatePage(String riskId,int pro_id) throws SQLException{
		MridentyVO vo=new MridentyVO();
		vo.setPro_id(pro_id);
		vo.setRisk_id(riskId);
		return riskIDAO.mrscore_updatePage(vo);
	}
	//취약성 식별 관련
	@Override
	public TbPublicVO tbpublicDataVlLevel(int base_lev1) throws SQLException{
		return riskIDAO.tbpublicDataVlLevel(base_lev1);
	}
	//위험수준산정 산정기준 등록
	@Override
	public void mrscore_insert(TtriskcalcVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.mrscore_insert(vo);
	}
	//위험수준산정 산정기준 등록(con2)
	@Override
	public void mrscore_insert1(TtriskcalcVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.mrscore_insert1(vo);
	}
	//위험수준산정 계산 컨테이너 vo값
	@Override
	public TtriskcalcVO mrscore_updatePageCal(int pro_id,String riskId) throws SQLException{
		TtriskcalcVO vo=new TtriskcalcVO();
		vo.setPro_id(pro_id);
		vo.setRisk_id(riskId);
		return riskIDAO.mrscore_updatePageCal(vo);
	}
	//위험수준산정 계산 컨테이너 값 수정
	@Override
	public void mrscore_update(TtriskcalcVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.mrscore_update(vo);
	}
	//위험수준산정 계산 컨테이너 값 수정 (con2)
	@Override
	public void mrscore_update1(TtriskcalcVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.mrscore_update1(vo);
	}
	
	
	
	//[위험처리계획수립]
	//(위험처리방안선정)
	//위험처리방안선정 페이지로 이동
	@Override
	public List mridenty3(Map map) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.mridenty3(map);
	}
	//위험처리방안선정 triskplan table값
	@Override
	public Map mridenty3_updatePage(int pro_id,String riskId) throws SQLException{
		TriskplanVO vo=new TriskplanVO();
		vo.setPro_id(pro_id);
		vo.setRisk_id(riskId);
		return riskIDAO.mridenty3_updatePage(vo);
	}
	//위험처리방안선정 산정기준 등록
	@Override
	public void mridenty3_insert(TriskplanVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.mridenty3_insert(vo);
	}
	//위험처리방안선정 계산 컨테이너 값 수정
	@Override
	public void mridenty3_update(TriskplanVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.mridenty3_update(vo);
	}
	
	
	
	
	
	//(자산위협매트릭스)
	//자산위협매트릭스 페이지로 이동
	/*
	@Override
	public List atmetrix(int pro_id, Map map) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.atmetrix(pro_id, map);
	}
	*/
	@Override
	public List atmetrix(int pro_id, ArrayList<MakindVO> list) throws SQLException {
		// TODO Auto-generated method stub
		return riskIjdbcDAO.atmetrix(pro_id, list);
	}
	//자산위협매트릭스 등록
	@Override
	public void insertAtmetrix(Map map) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.insertAtmetrix(map);
	}
	//자산위협매트릭스 삭제
	@Override
	public void deleteAtmetrix(Map map) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.deleteAtmetrix(map);
	}
	
	//(위험취약성매트릭스)
	//위험취약성매트릭스 페이지로 이동
	@Override
	public List tvmetrix(int pro_id, ArrayList<MtkindVO> list) throws SQLException {
		// TODO Auto-generated method stub
		return riskIjdbcDAO.tvmetrix(pro_id, list);
	}
	//위험취약성매트릭스 등록
	@Override
	public void insertTvmetrix(Map map) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.insertTvmetrix(map);
	}
	//위험취약성매트릭스 삭제
	@Override
	public void deleteTvmetrix(Map map) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.deleteTvmetrix(map);
	}
	

	
	
	//[위험수용]
	//(잔여위험평가)
	//잔여위험평가 페이지로 이동
	@Override
	public List mridenty4(Map map) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.mridenty4(map);
	}
	//잔여위험평가 trerisk table값
	@Override
	public Map mridenty4_updatePage(int pro_id,String riskId) throws SQLException{
		TreriskVO vo=new TreriskVO();
		vo.setPro_id(pro_id);
		vo.setRisk_id(riskId);
		return riskIDAO.mridenty4_updatePage(vo);
	}
	//잔여위험평가 등록
	@Override
	public void mridenty4_insert(TreriskVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.mridenty4_insert(vo);
	}
	//잔여위험평가 수정
	@Override
	public void mridenty4_update(TreriskVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.mridenty4_update(vo);
	}
	
	//[SoA정립]
	//(SoA정립)
	//SoA정립 페이지로 이동
	@Override
	public List msoa(int pro_id) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.msoa(pro_id);
	}
	//tsoa 데이터 확인용
	@Override
	public List tsoaData(Map map) throws SQLException {
		// TODO Auto-generated method stub
		return riskIDAO.tsoaData(map);
	}
	//SoA정립 등록페이지로 이동
	@Override
	public Map msoa_insertPage(Map map) throws SQLException{
		return riskIDAO.msoa_insertPage(map);
	}
	//SoA정립 수정페이지로 이동
	@Override
	public Map msoa_updatePage(Map map) throws SQLException{
		return riskIDAO.msoa_updatePage(map);
	}
	//SoA정립 등록
	@Override
	public void msoa_insert(MsoaVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.msoa_insert(vo);
	}
	//SoA정립 수정
	@Override
	public void msoa_update(MsoaVO vo) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.msoa_update(vo);
	}
	//SoA정립 삭제
	@Override
	public void msoa_delete(String tsAll,String proId) throws SQLException {
		// TODO Auto-generated method stub
		int pro_id=Integer.parseInt(proId);
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		map.put("tsAll",tsAll);
		riskIDAO.msoa_delete(map);
	}
	//SoA정립 list페이지에서 insert
	@Override
	public void msoa_SL_insert(Map map) throws SQLException {
		// TODO Auto-generated method stub
		riskIDAO.msoa_SL_insert(map);
	}
	
	
	
	//[현황관리]
	//지역/사이트
	@Override
	public List siteList(int pro_id) throws SQLException {
		return riskIDAO.siteList(pro_id);
	}
	//프로세스
	@Override
	public List procList(int pro_id) throws SQLException {
		return riskIDAO.procList(pro_id);
	}
	//보안 통제 영역 값
	@Override
	public List ts_nm2List(int pro_id) throws SQLException {
		return riskIDAO.ts_nm2List(pro_id);
	}
	//보안 통제 항목 값
	@Override
	public List ts_nm3List(int pro_id, String ts_nm2) throws SQLException {
		HashMap map=new HashMap();
		map.put("pro_id",pro_id);
		if(!ts_nm2.equals("0")){
			map.put("ts_nm2",ts_nm2);
		}
		return riskIDAO.ts_nm3List(map);
	}
	
	//현황 조회 
	@Override
	public List stateReportResult(StateReportVO vo) throws SQLException {
		return riskIDAO.stateReportResult(vo);
	}
	
	//엑셀 관련
	@Override
	public List excelData(Map map,String pageName) throws SQLException {
		return riskIDAO.excelData(map,pageName);
	}
	
	
	//엑셀 업로드
	@Override
	public Map excelUpload(int pro_id, String ext, String savedir, String filename, String reloadPageName) throws SQLException{
		HashMap map=new HashMap();
		HashMap mapz=new HashMap();
		try{
			
		if(ext.equals("xls")){
	    	  //poi 엑셀 관련
		      POIFSFileSystem fs=new POIFSFileSystem(new FileInputStream(savedir+filename));
	          HSSFWorkbook wb=new HSSFWorkbook(fs);
	          int sheetNum=wb.getNumberOfSheets(); //시트갯수 가져오기
	          //for(int i=0; i<sheetNum; i++){ //20110801 변경(시트 1만 사용)
	          for(int i=0; i<1; i++){
	        	  HSSFSheet sheet=wb.getSheetAt(i); //시트 가져오기
	        	  
	              int rows=sheet.getPhysicalNumberOfRows(); //행 갯수 가져오기
	              //for(int j=0; j<rows; j++){ //row 루프
	              for(int j=1; j<rows; j++){ //row 루프 // 1행은 제목줄
	                  HSSFRow row=sheet.getRow(j); //row 가져오기
	                  if(row!=null){
	                	  
	                      int cells=row.getPhysicalNumberOfCells(); //cell 갯수 가져오기
	                      for(short c=0; c<cells; c++){ //cell 루프
	                          HSSFCell cell=row.getCell(c); //cell 가져오기
	                          if(cell!=null){
	                              String value=null;
	                              switch(cell.getCellType()){ //cell 타입에 따른 데이타 저장
	                                  case HSSFCell.CELL_TYPE_FORMULA:
	                                      value=cell.getCellFormula();
	                                      break;
	                                  case HSSFCell.CELL_TYPE_NUMERIC:
	                                	  if (HSSFDateUtil.isCellDateFormatted(cell)){
	                                		  SimpleDateFormat formatter = new SimpleDateFormat("yyyy.MM.dd"); 
	                                          value=""+formatter.format(cell.getDateCellValue());
	                                          System.out.println(value);
	                                     } else{
	                                    	 value=""+(int)cell.getNumericCellValue();
	                                     }
	                                      break;
	                                  case HSSFCell.CELL_TYPE_STRING:
	                                      value=""+cell.getStringCellValue();
	                                      break;
	                                  case HSSFCell.CELL_TYPE_BLANK:
	                                      value=""+cell.getBooleanCellValue();
	                                	  //value=""+cell.getStringCellValue();
	                                      break;
	                                  case HSSFCell.CELL_TYPE_ERROR:
	                                      value=""+cell.getErrorCellValue();
	                                      break;
	                                  default:
	                              }
	                              //system.out.println("cell:"+(cell.getColumnIndex()+1)+", value:"+value);
	                              //stat.setString(count, value); //쿼리문 값 대입
	                              
	                              //system.out.println("cell:"+(cell.getColumnIndex()+1)+", value:"+value);
		                             //System.out.println("| 2 : "+cell.getCellType()); //셀의 타입인듯
		                              //System.out.println("| 7 : "+cell.getRawValue()); // 계속적인 숫자 증가
		                              //System.out.println("| 8 : "+cell.getReference()); // 엑셀 위치?(A, 2 같은거)
		                              //System.out.println("| 9 : "+cell.getRowIndex()); // 줄 순번(0번째줄, 1번째줄)
		                              //stat.setString(count, value); //쿼리문 값 대입
	                              map.put("cell"+(cell.getColumnIndex()+1), value);
	                          }
	                      }
	                      //stat.executeUpdate(); //쿼리문 insert 실행
	                  }
	                  map.put("cell0", pro_id);
	                  System.out.println(map);
	                  if(reloadPageName.equals("mrainfo")){
	                	  riskIDAO.mrainfo_insertExcel(map);
	                  }else if(reloadPageName.equals("mrainfoCon")){
	                	  riskIDAO.tracont_insertExcel(map);
	                  }else if(reloadPageName.equals("mraasset")){
	                	  //riskIService.mraasset_insertExcel(map);
	                  }
	                  //맵 초기화
	                  map=new HashMap();
	              }
	          }
	      }else if(ext.equals("xlsx")){
	    	  //poi 엑셀 관련
	    	  XSSFWorkbook wb = new XSSFWorkbook(new FileInputStream(new File(savedir+filename)));
	          int sheetNum=wb.getNumberOfSheets(); //시트갯수 가져오기

	          //for(int i=0; i<sheetNum; i++){
	          for(int i=0; i<1; i++){
	        	  XSSFSheet sheet=wb.getSheetAt(i); //시트 가져오기
	        	  
	              int rows=sheet.getPhysicalNumberOfRows(); //행 갯수 가져오기
	              //for(int j=0; j<rows; j++){ //row 루프
	              for(int j=1; j<rows; j++){ //row 루프 // 1행은 제목줄
	                  XSSFRow row=sheet.getRow(j); //row 가져오기
	                  if(row!=null){
	                	  
	                      int cells=row.getPhysicalNumberOfCells(); //cell 갯수 가져오기
	                      for(short c=0; c<cells; c++){ //cell 루프
	                          XSSFCell cell=row.getCell(c); //cell 가져오기
	                          if(cell!=null){
	                              String value=null;
	                              switch(cell.getCellType()){ //cell 타입에 따른 데이타 저장
	                                  case XSSFCell.CELL_TYPE_FORMULA:
	                                      value=cell.getCellFormula();
	                                      break;
	                                  case XSSFCell.CELL_TYPE_NUMERIC:
	                                	  if (HSSFDateUtil.isCellDateFormatted(cell)){
	                                		  SimpleDateFormat formatter = new SimpleDateFormat("yyyy.MM.dd"); 
	                                          value=""+formatter.format(cell.getDateCellValue());
	                                     } else{
	                                    	 value=""+(int)cell.getNumericCellValue();
	                                     }
	                                      break;
	                                  case XSSFCell.CELL_TYPE_STRING:
	                                      value=""+cell.getStringCellValue();
	                                      break;
	                                  case XSSFCell.CELL_TYPE_BLANK:
	                                	  //value=""+cell.getStringCellValue();
	                                      value=""+cell.getBooleanCellValue();
	                                      break;
	                                  case XSSFCell.CELL_TYPE_ERROR:
	                                      value=""+cell.getErrorCellValue();
	                                      break;
	                                  default:
	                              }
	                              //system.out.println("cell:"+(cell.getColumnIndex()+1)+", value:"+value);
	                             //system.out.println("| 2 : "+cell.getCellType()); //셀의 타입인듯
	                              //System.out.println("| 7 : "+cell.getRawValue()); // 계속적인 숫자 증가
	                              //System.out.println("| 8 : "+cell.getReference()); // 엑셀 위치?(A, 2 같은거)
	                              //System.out.println("| 9 : "+cell.getRowIndex()); // 줄 순번(0번째줄, 1번째줄)
	                              //stat.setString(count, value); //쿼리문 값 대입
	                              map.put("cell"+(cell.getColumnIndex()+1), value);
	                          }
	                      }
	                      //stat.executeUpdate(); //쿼리문 insert 실행
	                  }
	                  map.put("cell0", pro_id);
	                  System.out.println(map);
	                  if(reloadPageName.equals("mrainfo")){
	                	  riskIDAO.mrainfo_insertExcel(map);
	                  }else if(reloadPageName.equals("mrainfoCon")){
	                	  riskIDAO.tracont_insertExcel(map);
	                  }else if(reloadPageName.equals("mraasset")){
	                	  //riskIService.mraasset_insertExcel(map);
	                  }
	                  //맵 초기화
	                  map=new HashMap();
	              }
	          }
	      }
		
		mapz.put("errorCode", "");

		}catch (IOException e){
				try {
					deleteFile(savedir,filename);
				} catch (Exception e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			//System.out.println(e.getMessage());
			//mv.setViewName("failResult");
		}catch(Exception ex){
			TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
			
			Iterator it=map.keySet().iterator();
			while(it.hasNext()){
				String key=it.next().toString();
				System.out.println("key:"+key+" value:"+map.get(key));
				if(reloadPageName.equals("mrainfoCon")){
					if(key.equals("cell2")){
						mapz.put("errorCode", map.get(key));
					}
				}else{
					if(key.equals("cell1")){
						mapz.put("errorCode", map.get(key));
					}
				}
				
			}
			
		}
		
		return mapz;
	}
	
	public void deleteFile(String savedir, String filename) throws Exception{
		File fs = new File(savedir+filename);
		fs.delete();
	}
	
	
	//컨테이너 클릭 이벤트
	public boolean tracont2Flag(String proId, String racont_nm, String base_lev1) throws SQLException{
		int pro_id=Integer.parseInt(proId);
		HashMap map=new HashMap();
		map.put("pro_id", pro_id);
		map.put("racont_nm", racont_nm);
		map.put("base_lev1", base_lev1);
		return riskIDAO.tracont2Flag(map);
	}
	public List rainfoIDSelect(String proId, String racont_nm, String base_lev1) throws SQLException{
		int pro_id=Integer.parseInt(proId);
		HashMap map=new HashMap();
		map.put("pro_id", pro_id);
		map.put("racont_nm", racont_nm);
		map.put("base_lev1", base_lev1);
		return riskIDAO.rainfoIDSelect(map);
	}
	// 컨테이너에 컨테이너 유무 조회
	public List contSearch(String proId, String racont_nm, String base_lev1) throws SQLException{
		int pro_id=Integer.parseInt(proId);
		HashMap map=new HashMap();
		map.put("pro_id", pro_id);
		map.put("racont_nm", racont_nm);
		map.put("base_lev1", base_lev1);
		return riskIDAO.contSearch(map);
	}
}

